import flash.events.Event;
import flash.events.EventDispatcher;

class ShipModel extends CircleModel
{
  public var health:Int;
  public var firing:Int;

  public var money:Int;
  public var MaxHealth:Int;
  public var alive:Bool;

  public function new
    (type:String,inMaxHealth:Int, inInvincibilityLength, ?radius:Float = 30, ?color:Int = 0x999999)
  {
    super(type,radius,color);
    alive = true;
    health = inMaxHealth;
    MaxHealth = inMaxHealth;
    InvincibilityLength = inInvincibilityLength;
    firing = 0;
    invincible = 0;
    money = 0;
  }

  public override function update()
  {
    super.update();
  }
  
  public function heal()
  {
    if(health <= MaxHealth-1)
      {health++;}
  }

  public function hit()
  {
    if(invincible != 0)
      {return;}
    if(health > 0)
      {health--;}
    else
      {alive = false;}
   
  }
}